home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
UNIXLIB37B
/
!UnixLib37
/
src
/
pwd
/
c
/
getpwnam
< prev
next >
Wrap
Text File
|
1996-11-09
|
1KB
|
44 lines
/****************************************************************************
*
* $Source: /unixb/home/unixlib/source/unixlib37/src/pwd/c/RCS/getpwnam,v $
* $Date: 1996/10/30 22:04:51 $
* $Revision: 1.1 $
* $State: Rel $
* $Author: unixlib $
*
* $Log: getpwnam,v $
* Revision 1.1 1996/10/30 22:04:51 unixlib
* Initial revision
*
***************************************************************************/
static const char rcs_id[] = "$Id: getpwnam,v 1.1 1996/10/30 22:04:51 unixlib Rel $";
/* pwd.c.getpwnam. Search for an entry with a matching username.
This is a POSIX.1 function written by Nick Burrett, 13 October 1996. */
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <pwd.h>
/* Search for an entry with a matching name. */
struct passwd *
getpwnam (const char *name)
{
FILE *stream;
struct passwd *p;
stream = fopen ("/etc/passwd", "r");
if (stream == NULL)
return NULL;
while ((p = fgetpwent (stream)) != NULL)
if (!strcmp(p->pw_name, name))
break;
fclose (stream);
return p;
}